package com.icss.ah.fullGift.action;

import java.util.HashMap;
import java.util.Map;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.icss.ah.base.action.BaseAction;
import com.icss.ah.fullGift.service.FullGiftStatisticsService;
import com.icss.ah.login.bean.UserInfoBean;

/**
 * 满赠活动统计
 * @date 2017-8-9
 */
@Controller
@Scope("prototype")
public class FullGiftStatisticsAction extends BaseAction{

	private static final long serialVersionUID = -4846073399361179154L;
	
	@Autowired
	private  FullGiftStatisticsService fullGiftStatisticsService;
	
	private String giftId;
	private String giftName;
	private String begDate;
	private String endDate;
	private String orderNo;
	private String userName;
	
	/**
	 * 满赠活动列表页
	 */
	public String toGiftListPage(){
		return "toGiftListPage";
	}
	
	/**
	 * 满赠活动列表查询
	 */
	public void queryGiftList(){
		Map<String, String> map = getPara();
		map.put("giftName", giftName);
		dataGridJson = fullGiftStatisticsService.queryGiftList(map);
		str2Resp(JSONObject.fromObject(dataGridJson).toString());
	}
	
	/**
	 * 订单列表页
	 */
	public String toOrderListPage(){
		getRequest().setAttribute("giftId", giftId);
		return "toOrderListPage";
	}
	
	/**
	 * 订单列表查询
	 */
	public void queryOrderList(){
		Map<String, String> map = getPara();
		map.put("giftId", giftId);
		map.put("userName", userName);
		map.put("yhType", "5");
		map.put("orderNo", orderNo);
		dataGridJson = fullGiftStatisticsService.queryOrderList(map);
		str2Resp(JSONObject.fromObject(dataGridJson).toString());
	}
	
	/*
	 * 查询参数
	 */
	public Map<String, String> getPara(){
		String userCode=getUserCodeFromSession();
		UserInfoBean userInfo=getUserInfo(userCode);
		String shopId=userInfo.getShopId();
		String corpId = userInfo.getCorpId();
		Map<String, String> map = new HashMap<String, String>();
		map.put("shopId", shopId);
		map.put("corpId", corpId);
		map.put("begDate", begDate);
		map.put("endDate", endDate);
		map.put("startIndex", getStartIndexMysql());
		map.put("rowNums", getEndIndexMysql());
		return map;
	}

	public String getGiftId() {
		return giftId;
	}

	public void setGiftId(String giftId) {
		this.giftId = giftId;
	}

	public String getGiftName() {
		return giftName;
	}

	public void setGiftName(String giftName) {
		this.giftName = giftName;
	}

	public String getBegDate() {
		return begDate;
	}

	public void setBegDate(String begDate) {
		this.begDate = begDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

}
